package com.itheima.ssm.dao;

import com.itheima.ssm.domain.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

public interface PermissionDao {

    @Select("select * from permission where id in (select permissionId from role_permission where roleId = #{roleId})")
    List<Permission> findByRoleId(String roleId);

    @Select("select * from permission")
    List<Permission> findAll();

    @Insert("insert into permission (permissionname,url) values(#{permissionName},#{url})")
    void save(Permission permission);

    /**
     * 删除role_permission表中相应数据
     * @param id
     */
    @Delete("delete from role_permission where permissionId=#{id}")
    void del_role_permission(String id);

    /**
     * 删除permission表中相应数据
     * @param id
     */
    @Delete("delete from permission where id=#{id}")
    void delete(String id);
}
